import { Reducer, Effect } from 'umi';

export interface normalTableState {
  total: number,
  page: {
    page: number,
    size: number
  }
  filter?: {},
  data: any[]
}

const initState: normalTableState = {
  total: 0,
  page: {
    page: 1,
    size: 10
  },
  filter: {},
  data: []
}

interface normalTableType {
  namespace: string,

  state: normalTableState,

  effects: {
    queryList: Effect
  },
  reducers: {
    saveData: Reducer<normalTableState>
    clear:Reducer<normalTableState>
  }
}

const normalTable: normalTableType = {
  namespace: 'normalTable',
  state: initState,
  effects: {
    *queryList({ payload }, { call, put }) {

    }
  },
  reducers: {
    saveData(state, { payload }) {
      // console.log(payload);
      
      return {
        ...state,
        ...payload
      }
    },
    clear(state) {
      return {
        ...initState
      }
    }
  }
}

export default normalTable;